/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"B955F04A-2BA1-4A3B-98B4-2210B7F5E058",variableType:4}
 */
var mue_subcap = null;

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"955D170A-3B5D-4319-8D36-16A35370DB87"}
 */
function onShow(firstShow, event) {
		controller.sort("codigo asc")
}

/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"09792DA1-D4E8-4268-828C-8E1DA1118CEF"}
 */
function onDataChange_codigo(oldValue, newValue, event) {
	if (controller.getSelectedIndex() == 1 && globals.gEstadoAbm == 1)
	{
		elements.nombre.requestFocus()
		return true
	}
	else
	{
		elements.nombre.requestFocus()
		codigo = oldValue
		return true
	}
}

/**
 * @properties={typeid:24,uuid:"74425078-61A4-4A7E-AA50-234A715C4FBF"}
 */
function validar() {
	controller.setSelectedIndex(1)
	if (globals.gEstadoAbm == 1)
	{
		var $sql = 'SELECT rubro_id FROM tipos WHERE empresa = ? AND codigo = ?'
		var $args = [empresa, codigo]
		var $ds = databaseManager.getDataSetByQuery('contable',$sql,$args,-1)
		if ($ds.getMaxRowIndex() != 0) 
		{		
			return [false,false,"El código ingresado ya existe"]
		}
	}
	return [true]
}

/**
 * @properties={typeid:24,uuid:"208C4B14-54A7-4F81-99B3-4D1D45D3127B"}
 */
function imprimir()
{
	//forms.tipos_impresion.controller.showPrintPreview()
	jasper('impresion')
}

/**
 * @properties={typeid:24,uuid:"32C26EB9-3714-4EC4-8E7A-7C363A190269"}
 */
function pdf()
{
	//globals.metodoPdf('tipos_impresion','Tipos - ' + globals.glegajo,true)
	jasper('pdf')
}

/**
 * @properties={typeid:24,uuid:"A6751CCD-8F4D-4D75-B105-49CFFDDAC748"}
 */
function xls()
{
	jasper('xls')
}

/**
 * @properties={typeid:24,uuid:"CFE23211-387D-4300-927F-B0A06B620A6F"}
 */
function csv()
{
	jasper('csv')
}

/**
 * @param {String} tipo
 *
 * @properties={typeid:24,uuid:"C12E3B11-6E6F-4252-92B3-B5FDEA49279F"}
 */
function jasper(tipo)
{
	var $params = {
		userv: usuarios_to_uservs.razon_social
	}
	var $cols = ['codigo','nombre','vida','tipos_to_cuentas_amort_acum.cuenta_impresion','tipos_to_cuentas_amort_ej.cuenta_impresion','tipos_to_cuentas_contable.cuenta_impresion']
	var $ds	= databaseManager.convertToDataSet(foundset,$cols)
	$ds.setColumnName(3,'cta_amoacu')
	$ds.setColumnName(4,'cta_amo')
	$ds.setColumnName(5,'cta_bus')
	globals.metodoJasper(tipo,'contable/tipos_bienes.jasper','Tipos_Bienes',$ds,$params)
}